<template>
    <div>
      <m-head title="我的钱包"></m-head>
      <div class="top">
        <img src="../../static/images/walletbg.png" alt="">
        <p>可用金币：<span>{{money}}</span></p>
      </div>
      <div class="mx">
        <div class="title">
          <h3>收支明细</h3>
        </div>
        <div class="item" v-for="(item,key) in list" :key="key">
          <div class="left">
            <h3>{{item.name}}</h3>
            <p>{{t2s(item.created_at)}}</p>
          </div>
          <span class="add">{{item.type == 1 ? '+':'-'}}{{item.money}}</span>
        </div>
      </div>
    </div>
</template>

<script>
import MHead from './MHeader'
import * as info from '../api/info'
import store from '../utils/store'
import * as t from '../utils/time'
export default {
  name: 'my-wallet',
  components: {
    'm-head': MHead
  },
  data () {
    return {
      list: {},
      money: 0
    }
  },
  mounted () {
    this.getInfo()
    this.money = store.getters.getUserInfo.money
  },
  methods: {
    getInfo () {
      let that = this
      info.accountDetail().then(res => {
        that.list = res.data
      })
    },
    t2s (time) {
      return t.t2s(time)
    }
  }
}
</script>

<style scoped>
.top{
  display: flex;
  align-items: center;
  padding: .2rem .3rem;
  border-bottom: 10px solid #f2f2f2;
}
.top img{
  width: 2rem;
  margin-right: .2rem;
}
.top p{
  font-size: .4rem;
}
.top p span{
  color: #fc6a00;
  font-weight: bold;
}
.mx{
}
.mx .title{
  height: 1.2rem;
  line-height: 1.2rem;
  padding-left: .3rem;
  border-bottom: 1px solid #eee;
}
.mx .title h3{
  padding-left: .3rem;
  position: relative;
  font-size: .44rem;
}
.mx .title h3::before{
  content: '';
  position: absolute;
  top: 25%;
  left: 0;
  height: 50%;
  border-left: 3px solid #fc6a00;
}
.item{
  padding: .2rem .3rem .2rem .6rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.item .left h3{
  font-size: .38rem;
  margin-bottom: .1rem;
  color: #000;
}
.item .left p{
  color: #888;
  font-size: .34rem;
}
.item span{
  color: #333;
  font-size: .4rem;
}
.item span.add{
  color: #fc6a00;
}
a{
}
</style>
